package com.hdf.etdemo.dialog.bigkoo;

import com.hdf.easytools.base.EasyToolsActivity;
import com.hdf.easytools.dialog.bigkoo.SVProgressHUD;
import com.hdf.etdemo.R;

import android.app.Activity;
import android.content.Context;
import android.os.Bundle;
import android.os.Handler;
import android.os.Message;
import android.view.KeyEvent;
import android.view.View;


public class DialogActivity extends EasyToolsActivity {
	int progress = 0;
	private Context context = DialogActivity.this;

	@Override
	protected void onCreate(Bundle savedInstanceState) {
		super.onCreate(savedInstanceState);
		setContentView(R.layout.activity_dialog);
		/**设置标题显示*/
		this.TitleVisib(0, 1, 1, 0, 0);
		/**绑定标题点击事件*/
		this.TitleClick(0, 1, 0, 0, 0);
		/**设置标题样式ʽ*/
		this.TitleStyle(null,R.drawable.et_back, "个性弹框", null,0);
		

	}
	public void show(View view){
        SVProgressHUD.show(this);
    }
    public void showWithMaskType(View view){
        SVProgressHUD.showWithMaskType(this, SVProgressHUD.SVProgressHUDMaskType.None);
//        SVProgressHUD.showWithMaskType(this,SVProgressHUD.SVProgressHUDMaskType.Black);
//        SVProgressHUD.showWithMaskType(this, SVProgressHUD.SVProgressHUDMaskType.BlackCancel);
//        SVProgressHUD.showWithMaskType(this, SVProgressHUD.SVProgressHUDMaskType.Clear);
//        SVProgressHUD.showWithMaskType(this, SVProgressHUD.SVProgressHUDMaskType.ClearCancel);
//        SVProgressHUD.showWithMaskType(this, SVProgressHUD.SVProgressHUDMaskType.Gradient);
//        SVProgressHUD.showWithMaskType(this, SVProgressHUD.SVProgressHUDMaskType.GradientCancel);
    }
    public void showWithStatus(View view){
        SVProgressHUD.showWithStatus(this, "加载中...");
    }
    public void showInfoWithStatus(View view){
        SVProgressHUD.showInfoWithStatus(this, "这是提示", SVProgressHUD.SVProgressHUDMaskType.None);
    }
    public void showSuccessWithStatus(View view){
        SVProgressHUD.showSuccessWithStatus(this, "恭喜，提交成功！");
    }
    public void showErrorWithStatus(View view){
        SVProgressHUD.showErrorWithStatus(this, "不约，叔叔我们不约～", SVProgressHUD.SVProgressHUDMaskType.GradientCancel);
    }
    Handler mHandler = new Handler(){
        @Override
        public void handleMessage(Message msg) {
            super.handleMessage(msg);
            progress = progress + 5;
            if (SVProgressHUD.getProgressBar(context).getMax() != SVProgressHUD.getProgressBar(context).getProgress()) {
                SVProgressHUD.getProgressBar(context).setProgress(progress);
                SVProgressHUD.setText(context, "进度 "+progress+"%");

                mHandler.sendEmptyMessageDelayed(0,500);
            }
            else{
                SVProgressHUD.dismiss(context);
                SVProgressHUD.getProgressBar(context).setProgress(0);
            }

        }
    };
    public void showWithProgress(View view){
        SVProgressHUD.showWithProgress(this, "进度 "+progress+"%", SVProgressHUD.SVProgressHUDMaskType.Black);
        progress = 0;
        mHandler.sendEmptyMessageDelayed(0,500);
    }

    @Override
    public boolean onKeyDown(int keyCode, KeyEvent event)
    {
        if (keyCode == KeyEvent.KEYCODE_BACK && event.getRepeatCount() == 0)
        {
            if(SVProgressHUD.isShowing(this)){
                SVProgressHUD.dismiss(this);
                return false;
            }
        }

        return super.onKeyDown(keyCode, event);

    }
    @Override
	public void onClick(View v) {
		// TODO Auto-generated method stub
		switch (v.getId()) {
		case R.id.left_img:
				finish();
			break;

		default:
			break;
		}
	}
}
